package com.yh.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.yh.bean.PersonApply;
import com.yh.bean.Rules;
import com.yh.dao.RulesDao;
import com.yh.service.RulesService;


@Service("rulesImp")
@Transactional
public class RulesImp implements RulesService {
	
	@Autowired
	private RulesDao rd;

	@Override
	public int addRules(Rules rule) {
		if(rd.addRules(rule)!=0){
			return 1;
		}
		return 0;
	}

	@Override
	public int deleteRules(Rules rule) {
		if(rd.deleteRules(rule)!=0){
			return 1;
		}
		return 0;
	}

	@Override
	public Map queryRules(Rules rule,int curr) {		
		Page<PersonApply> page=PageHelper.startPage(curr,2);
		 List<Rules>  lp=rd.queryRules(rule);
		 long count = page.getTotal();
			 Map map=new HashMap();
			 map.put("count", count);
			 map.put("rules", lp);
		
	  return  map ;
	}

	@Override
	public int updateRules(Rules rule) {
		if(rd.updateRules(rule)!=0){
			return 1;
		}
		return 0;
	}

	
	@Override
	public int deleteArrayRules(int[] array) {
		  if(rd.deleteArrayRules(array)!=0){
			  return 1;
		  }
		return 0;
	}

	
}
